#!/usr/bin/python
import time, math

### copy from http://www.progsoc.uts.edu.au/wiki/index.php/Category:Euler

start_time = time.time()

def isPrime(num):
        for i in range(2,int(math.sqrt(num))+1):
                if (num%i) == 0:
                        return False
        return True

#Start prime number generator
#We'll start with 100 attempts to get primes. If that's not enough, I'll up it.
primes = [2,3,5]
for i in range(1,1000):
        if isPrime(6*i+1):
                primes.append(6*i+1)
        if isPrime(6*i+5):
                primes.append(6*i+5)
primes.sort()

num=0
curnum=0
consecutive=0
curcon=0
#we have a thousand elements in our array. The answer won't necessarily start with the first prime...
for k in range(0,1000):
        curcon=0
        curnum=0
        #Trim off any values already used as a starting point....
        for i in primes[k:]:
                if(curnum+i >= 1000000):
                        break
                curnum += i
                curcon += 1
                if isPrime(curnum) and curcon>consecutive:num,consecutive=curnum,curcon
        
print (num)
run_time = time.time() - start_time
print (run_time)
